﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using BusinessTier;
using DataTier;

namespace BookingService
{

    public class BookService : IBookingService
    {
        private static IBBooking bookingObj = new BBooking();
        private static IBStation stationObj = new BStation();
        private static IBCustomer cusObj = new BCustomer();
        private static IBBattery batObj = new BBattery();
        private static IBSubscription subObj = new BSubscription();

        //public void AcceptBooking(Booking b)
        //{
        //    bookingObj.AcceptBooking(b);
        //}

        public List<Station> GetAllStations()
        {
            return stationObj.GetAllStations();

        }

        public IList<Customer> GetAllCustomers()
        {
            return cusObj.GetAllCustomers();
        }


        public Battery FindAvailableBattery(int stationId, DateTime bookingDateTime)
        {
            return batObj.FindAvailableBattery(stationId, bookingDateTime);
        }


        public void DeleteCustomerById(int id)
        {
            cusObj.DeleteCustomerById(id);
        }

        public void UpdateCustomer(int id, string uName, string name, string address, int zip, string email, string password)
        {
            cusObj.UpdateCustomer(id, uName, name, address, zip, email, password);
        }

        public void CreateCustomer(string uName, string name, string address, int zip, string email, string password)
        {
            cusObj.CreateCustomer(uName, name, address, zip, email, password);
        }

        public string GetCityFromZip(int zip)
        {
            return cusObj.GetCityFromZip(zip);
        }

        //public List<Station> GetStations()
        //{
        //    return stationObj.GetStations();
        //}

        public List<Edge> GetAllEdges()
        {
            return stationObj.GetAllEdges();
        }

        public List<Battery> GetBatteriesInStation(int stationId)
        {
            return batObj.GetBatteriesInStation(stationId);
        }

        public void AddBatteryToStation(int stationId)
        {
            batObj.AddBatteryToStation(stationId);
        }

        public void CreateStation(string name, string address, int zip)
        {
            stationObj.CreateStation(name, address, zip);
        }

        public void CreateEdge(int fromStation, int toStation, int cost)
        {
            stationObj.CreateEdge(fromStation, toStation, cost);
        }

        public void DeleteStation(int stationId)
        {
            stationObj.DeleteStation(stationId);
        }

        public void DeleteEdgeFrom(int stationId)
        {
            stationObj.DeleteEdgeFrom(stationId);
        }

        public void DeleteEdgeTo(int stationId)
        {
            stationObj.DeleteEdgeTo(stationId);
        }


        public Station FindShortestRoute(int fromZip, int toZip)
        {
            return bookingObj.FindShortestRoute(fromZip, toZip);
        }

        public List<Booking> getAllBookings(int sId)
        {
            return bookingObj.getAllBookings(sId);
        }


        public List<Subscription> GetSubscriptions(int cId)
        {
            return subObj.GetSubscriptions(cId);
        }


        public Route CalculateRoute(int fromZip, string fromCity, string fromAdress, bool dateIsStart, DateTime date, int toZip, string toCity, string toAdress, Customer customer, Subscription subscription)
        {
            return bookingObj.CalculateRoute(fromZip, fromCity, fromAdress, dateIsStart, date, toZip, toCity, toAdress, customer, subscription);
        }

        public void AcceptRoute(Route route, Customer customer, Subscription subscription)
        {
            bookingObj.AcceptRoute(route, customer, subscription);
        }

        public Customer GetCustomerByUserName(string username)
        {
            return cusObj.GetCustomerByUserName(username);
        }
    }
}

